package com.controller;

import com.bean.Bumen;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.service.BumenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/bumen")

public class BumenController {
    @Autowired
    private BumenService bumenService;


    @RequestMapping(path = "/getbumenbyid/{id}", method = RequestMethod.GET)
    @HystrixCommand(fallbackMethod = "process_Hystrix_getBumenById")
    public Bumen getBumenById(@PathVariable("id") Integer id) {
        Bumen bumen = bumenService.findById(id);
        if (bumen==null){
            throw new RuntimeException("该id"+id+"不存在");
        }
        return bumen;
    }
    public Bumen process_Hystrix_getBumenById(@PathVariable("id") Integer id) {
        return new Bumen().setBm_id(id).setBm_name("该id没有对应的部门id，@null--hystrix");
    }



}
